﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Edge.Business.Entities;
using Edge.Common.Services;
using Edge.Common.Utils;
using Shop.Business.Domain.Catalog;
using Shop.Business.Domain.Customers;
using Shop.Business.Domain.Orders;
using Shop.Business.Domain.Pricing;

namespace Shop.Business.Domain.Orders
{
    /// <summary>
    /// Users object for NHibernate mapped table 'order_item'.
    /// </summary>
    [Serializable]
    public class OrderItem : EntityWithStat<int>
    {

        protected Order order;
        protected Product product ;
        protected bool addSize;
        protected decimal price;
        protected decimal sellPrice;
        protected int qty;
        protected int discount;
        protected PriceItem priceItem;

        public virtual Order Order
        {
            get { return order; }
            set { order = value; }
        }

        public OrderItem()
        {
        }

        public virtual decimal Itog
        {
            get
            {
                decimal ret = order.OrderStatus == OrderStatus.Draft ? product.Price*qty : price*qty;
                return ret;
            }
        }

        //for no order
        public OrderItem(Product product1, bool addSize1, int qty1)
        {
            this.product = product1;
            this.addSize = addSize1;
            this.qty = qty1;
            this.price = product1.Price;
            this.priceItem = product1.PriceItem;
        }

        public virtual Product Product
        {
            get { return product; }
            set { product = value; }
        }

        public virtual bool AddSize
        {
            get { return addSize; }
            set { addSize = value; }
        }

        public virtual decimal Price
        {
            get { return price; }
            set { price = value; }
        }

        public virtual int Quantity
        {
            get { return qty; }
            set { qty = value; }
        }

        public virtual PriceItem PriceItem
        {
            get { return priceItem; }
            set { priceItem = value; }
        }

        public virtual decimal SellPrice
        {
            get { return sellPrice; }
            set { sellPrice = value; }
        }

        public virtual int Discount
        {
            get { return discount; }
            set { discount = value; }
        }

        //public void Accept(IItemsVisitor visitor);
    }

}